<div id='stage_<%= stage.id %>_type_<%= type.id %>_cd_designer_form' class='new_or_edit'>
  <div class='form'>
    <dl>
      <dt>【<%= stage.name %>】-设计师：</dt>
    </dl>
    <div class="item">
      <%= select_tag :department_id,
            Department.all.each_with_object([]) {  | department, array | array <<  "<option value='#{department.id}' #{ "selected='selected'" if department.id == params[:department_id].try(:to_i)}>#{department.name}</option>"} .join('') ,
            :id => "stage_#{stage.id}_type_#{type.id}_department_id",
            :onchange => remote_function(
              :update => "stage_#{stage.id}_type_#{type.id}_designers",
              :url => new_in_work_item_designer_work_item_url(:default),
              :method => :get,
              :with => "'&stage_id=#{stage.id}&work_item_type_id=#{type.id}&department_id=' + $F('stage_#{stage.id}_type_#{type.id}_department_id')"
            )
        %>
    </div>
    <% @designers.each do |designer| %>
      <div class='item'>
        <div class='name'><%= designer.full_name %></div>
        <div id="stage_<%= stage.id %>_type_<%= type.id %>_<%= designer.id %>_tools" class='tools'>
          <% if designer.exist?( :stage_id => stage.id, :work_item_type_id => type.id) %>
            已加入
          <% else %>
            <%= link_to_remote '加入',
                  :update => "stage_#{stage.id}_type_#{type.id}_designers",
                  :url => create_in_work_item_designer_work_items_url(
                    :designer_work_item => {
                      :stage_id => stage.id,
                      :work_item_type_id => type.id,
                      :designer_id => designer.id
                    }
                  ),
                  :with => "'&department_id=' + $F('stage_#{stage.id}_type_#{type.id}_department_id')",
                  :mehtod => :post,
                  :loading => text_loader("stage_#{stage.id}_type_#{type.id}_#{designer.id}_tools"),
                  :html => {
                    :class => :base
                  }
              %>
          <% end %>
        </div>
      </div>
    <% end %>
  </div>
  <div class='buttons'>
    <%= link_to_function '返回', "Effect.Fade('stage_#{stage.id}_type_#{type.id}_designers');", :class => 'go_back button'  %>
  </div>
</div>